<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
  <el-dialog :visible.sync="localShow" width="360px" title="线索管理" :destroy-on-close="true"
    :close-on-click-modal="false">
    <!-- <div class="thread-form" v-cloak> -->
    <el-form size="small" label-width="100px" label-position="right" v-loading="loading">
      <el-form-item label="客户姓名">
        <el-input size="mini" v-model="item.name" minlength="0" :disabled="item.id ? true : false"
          ></el-input>
      </el-form-item>

      <el-form-item label="手机号">
        <el-input size="mini" v-model="item.mobile" minlength="0" :disabled="item.id ? true : false"
          ></el-input>
      </el-form-item>

      <el-form-item label="备注">
        <el-input type="textarea" :rows="5"  placeholder="请输入备注" v-model="item.remark">
        </el-input>
      </el-form-item>


    </el-form>
    <div slot="footer">
      <el-button :loading="loading" type="default" @click="() => this.$emit('change', null)" size="mini">取消</el-button>
      <el-button :loading="loading" type="primary" @click="submitHandle" size="mini">确定</el-button>
    </div>
    <!-- </div> -->
  </el-dialog>
</template>

<script>
import { updateThread, createThread, deleteThread } from "@/api/thread";
import PostSelector from "@/components/PostSelector";
import BrokerSelector from "@/components/BrokerSelector";
export default {
  components: { PostSelector, BrokerSelector },
  data() {
    return {
      loading: false,
    };
  },
  props: {
    item: { type: Object, default: null },
    show: { type: Boolean, default: false },
    pid: { type: Number, default: null },
  },
  computed: {
    localShow: {
      get() {
        return this.show;
      },
      set(val) {
        if (!val) {
          this.$emit("change", null);
        }
      },
    },
  },

  mounted: function () { },

  methods: {
    submitHandle: function () {
      var data = this.item;
      data.post_id = this.pid;
      this.loading = true;
      if (!data.id) {
        createThread(data).then((resp) => {
          this.loading = false;
          if (resp.status == 0) {
            this.$message.success("已保存");
            this.$emit("change", null);
          }
        });

        return;
      }
      updateThread(data).then((resp) => {
        this.loading = false;
        if (resp.status == 0) {
          this.$message.success("已保存");
          this.$emit("change", null);
        }
      });
    },
  },
};
</script>

<style scoped>
.room-form {
  margin-top: 20px;
}
</style>